<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itcast" uri="http://itcast.cn/common/"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>流浪动物管理</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Modern Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template, 
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
 <!-- Bootstrap Core CSS -->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/bootstrap.css">
<!-- Custom CSS -->
<link href="${pageContext.request.contextPath }/css/style1.css" rel='stylesheet' type='text/css' />
<link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css"> 
<!-- jQuery -->
<script src="${pageContext.request.contextPath }/js/jquery-1.11.0.js"></script>
<!--kindeditor的js  -->
<script charset="utf-8" src="${pageContext.request.contextPath }/js/kindeditor/kindeditor-all-min.js" type="text/javascript"></script>
<script charset="utf-8" src="${pageContext.request.contextPath }/js/kindeditor/lang/zh-CN.js" type="text/javascript"></script>
<!---//webfonts--->  
<!-- Bootstrap Core JavaScript -->
<script src="${pageContext.request.contextPath }/js/bootstrap.js"></script>
<script type="text/javascript">  
			var editor;
			KindEditor.ready(function(K) {
			  editor = K.create('textarea[name="adfoundpetdesc"]', {
				  	items: ['fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', '|', 'emoticons', 'image', 'link','|','preview'],
				  afterBlur:function(){this.sync();},
			       resizeType: 1,
			       allowPreviewEmoticons: false
			    });
			    
			});
</script>
    <script>
    	 /*全选或全不选*/
			//1.页面加载
			$(function(){
				//2.获取下面的复选框并将其选中状态设置跟编码的前端复选框保持一致
				$("#select").click(function(){
					 //atrr方法与JQ的版本有关，在1.8.3以下有关
					//$("tbody input[class='selectOne']").attr("checked",this.checked);
					$("tbody input[class='selectOne']").prop("checked",this.checked);
					
				});
			});
			/*全选删除*/
			function jjj(){
				var pList = "";
	            $("[name='all']").each(function () {
	                if ($(this).is(':checked')) {
	                    pList += $(this).val() + ",";
	                }
	            });
	            //去除最后的，
	           pList=pList.substr(0,pList.length-1);
	           var ids = pList;
	           if(pList==""){
	           	alert("请选择");
	           }else{
	           	var yes = confirm("你确定要删除吗?");
	           	if(yes){
	           		$.post(
	           			"<%=basePath%>adminStray/delStrayss",
	           			{"ids":ids},
	           			function (data) {
							alert("删除成功!");
							location.href="<%=basePath%>adminStray/stray";
						}
	           		);
	           	}
	           }

			}
			
		</script>

</head>
<body>
<div id="wrapper">
     <!-- Navigation -->
        <jsp:include page="/WEB-INF/jsp/admin/common.jsp"></jsp:include>
        
        
        <div id="page-wrapper">
          <div class="row" style="background-color: wheat;">
           <div class=""></div>
              <div class="col-lg-10 navbar-left" style="padding-top: 15px;margin-left:10px;">
               <form class="form-inline" id="" action="${pageContext.request.contextPath }/adminStray/stray" method="post">
               	      <div class="form-group">
					    <label for="skind">品种:</label>
					    <select id="skind" name="skind">
									<option value="">--请选择--</option>
									<option value="1" <c:if test="${skind == 1 }">selected</c:if>>狗狗</option>
									<option value="2" <c:if test="${skind == 2 }">selected</c:if>>猫猫</option>
									<option value="3" <c:if test="${skind == 3 }">selected</c:if>>其他</option>
								</select>
					  </div>
					  
					  <div class="form-group">
					    <label for="ssex">性别:</label>
					    <select id="ssex" name="ssex">
									<option value="">--请选择--</option>
									<option value="1" <c:if test="${ssex == 1 }">selected</c:if>>男</option>
									<option value="2" <c:if test="${ssex == 2 }">selected</c:if>>女</option>
								</select>
					  </div>
					  <div class="form-group">
					    <label for="saccept">受理:</label>
					    <select id="saccept" name="saccept">
									<option value="">--请选择--</option>
									<option value="1" <c:if test="${saccept == 1 }">selected</c:if>>是</option>
									<option value="2" <c:if test="${saccept == 2 }">selected</c:if>>否</option>
								</select>
					  </div>
					  
					  <div class="form-group">
					    <label for="sdate">上报日期：</label>
					    <input type="date" class="form-control" id="sdate" name="sdate" value="${sdate }">
					  </div>
					  
					   
					   
						  
					  <button type="submit" class="btn btn-default">搜索</button>
					</form>
              </div>
           </div>
           
        <div class="row">
        <div class="col-md-12">  
  	       <h3>流浪动物管理</h3>
  	        <div class="bs-example4" data-example-id="contextual-table">
              <table class="table table-hover">
	             <caption><input type="checkbox" id="select">
	             	<a href="#" class="btn btn-danger btn-sm" onclick="jjj()">
									<span class="glyphicon glyphicon-trash"></span> 批量删除
								</a>
	             </input>
	             </caption>
					<thead>
						<tr>
							<th>序号</th>
							<th>图片</th>
							<th>品种</th>
							<th>性别</th>
							<th>颜色</th>
							
							<th>时间</th>
							<th>地址</th>
							<th>攻击性</th>
							<th>上报人</th>
							<th>联系方式</th>
							<th>受理</th>
							<th>操作</th>
							
						</tr>
					</thead>
						<tbody>
						<c:forEach var="row" items="${page.rows }" varStatus="vs">
							<tr>
								<td><input type="checkbox" class="selectOne" value="${row.id }" name="all"/><span id="" style="padding-left: 5px;">${vs.count }</span></td>
								
								 <td>
								  <img src="${row.fimage }" class="img-thumbnail" alt="Cinque Terre" width="30px" height="30px">
								 </td>
								
								<c:if test="${row.fkind == 1}">
								<td>狗狗</td>
								</c:if>
								
								<c:if test="${row.fkind == 2}">
								<td>猫猫</td>
								</c:if>
								
								<c:if test="${row.fkind == 3}">
								<td>其他</td>
								</c:if>
								<td>${row.fsex ==1?"男":"女" }</td>
								<td>${row.fcolor }</td>
								<td>${row.ftime }</td>
								
								<td>${row.faddress }</td>
								
								<c:if test="${row.fattach==1 }">
								<td>有</td>
								</c:if>
								<c:if test="${row.fattach==2 }">
								<td>无</td>
								</c:if>
								<td>${row.fman }</td>
								<td>${row.ftel }</td>
								<c:if test="${row.isaccept==1 }">
								<td>已受理</td>
								</c:if>
								<c:if test="${row.isaccept==2 }">
								<td>未受理</td>
								</c:if>
								
								<td>
								<!--查看详情-->
								<c:if test="${row.isaccept==2 }">
								<a href="#" onclick="detailStray(${row.id })">
									<!--<span class="glyphicon glyphicon-edit"></span>-->
									<button class="btn btn-info btn-sm glyphicon glyphicon-edit" data-toggle="modal" data-target="#myModal">
											查看详情
											</button>
								</a>
								
								&nbsp;&nbsp;
								</c:if>
								<!--删除-->							
								<a href="#" class="btn btn-danger btn-sm" onclick="delStray(${row.id })">
									<span class="glyphicon glyphicon-trash"></span> 删除
								</a>
								
							</td>	
							</tr>
							</c:forEach>
							
					</tbody>
				</table>
				<div class="col-md-12 text-right">
							<span>共<font style="color: red;">${total}</font>条数据</span><itcast:page url="${pageContext.request.contextPath }/adminStray/stray" />
						</div>
             </div>
            </div>
            </div>
            
            
      </div>
      <!-- /#page-wrapper -->
   </div>
   
  
		
		<!--编辑弹出层-->
		<div class="update_modal">
		<!-- 模态框（Modal） -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content" style="background-color:#A6A6A6;">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
				</button>

						<h4 class="modal-title" id="myModalLabel">
					详情
				</h4>
					
					<form class="form-horizontal" role="form" id="strayForm" method="post">
						
						<div class="form-group">
							
							<div class="col-sm-4">
								<input type="hidden" class="form-control" id="id" name="id">
							</div>
						</div>
	
						
						
						<div class="form-group">
							<label for="fimage1" class="col-sm-2 control-label">图片</label>
							<div class="col-sm-4">
								<img src="${pageContext.request.contextPath }/img/1.png" id="fimage1" name="fimage1" style="width: 100px; height: 100px;"/>
								<input type="hidden" id="fimage" name="fimage">
							</div>
						</div>
						
						<div class="form-group">
							<label for="skind1" class="col-sm-2 control-label">品种</label>
							<div class="col-sm-4">
								<span id="fkind" name="fkind"></span>
								
							</div>
						</div>
						
						<div class="form-group">
							<label for="fsex" class="col-sm-2 control-label">性别</label>
							<div class="col-sm-4">
								<span id="fsex" name="fsex"></span>
								
							</div>
						</div>
						
						<div class="form-group">
							<label for="fcolor" class="col-sm-2 control-label">颜色</label>
							<div class="col-sm-4">
								<span id="fcolor" name="fcolor"></span>
								
							</div>
						</div>
						
						<div class="form-group">
							<label for="ftime" class="col-sm-2 control-label">时间</label>
							<div class="col-sm-4">
							<span id="ftime" name="ftime"></span>
								
							</div>
						</div>
						
						
						<div class="form-group">
							<label for="faddress1" class="col-sm-2 control-label">地址</label>
							<div class="col-sm-4">
								<span id="faddress1" name="faddress1"></span>
								<input type="hidden" id="faddress" name="faddress">
							</div>
						</div>
						
						<div class="form-group">
							<label for="fattach" class="col-sm-2 control-label">攻击性</label>
							<div class="col-sm-6">
								<span id="fattach" name="fattach"></span>
								
							</div>
						</div>
						<div class="form-group">
							<label for="fdesc" class="col-sm-2 control-label">描述</label>
							<div class="col-sm-8">
								<!-- <span id="fdesc" name="fdesc" style="width: 450px; height: 250px;"></span> -->
								<textarea id="adfoudpet_id" name="adfoundpetdesc" style="width:100%;height:250px;border: 0 none;visibility:hidden;"></textarea>
            						<textarea rows="" cols="" name="fdesc" id="fdesc" style="width:100%;height:250px;display:none;"></textarea>
							</div>
						</div>
						
						<div class="form-group">
							<label for="fman1" class="col-sm-2 control-label">发现人</label>
							<div class="col-sm-4">
								<span id="fman1" name="fman1"></span>
								<input type="hidden" id="fman" name="fman">
							</div>
						</div>
						
						<div class="form-group">
							<label for="ftel" class="col-sm-2 control-label">联系方式</label>
							<div class="col-sm-4">
								<span id="ftel" name="ftel"></span>
								
							</div>
						</div>
						<div class="form-group">
							<label for="femail1" class="col-sm-2 control-label">邮箱</label>
							<div class="col-sm-4">
								<span id="femail1" name="femail1"></span>
								<input type="hidden" id="femail" name="femail">
							</div>
						</div>
						
						<div class="form-group">
							<label for="isaccept" class="col-sm-2 control-label">受理</label>
							<div class="col-sm-4">
								<span id="isaccept" name="isaccept"></span>
								
							</div>
						</div>
						
						<!--<div class="form-group">
							<label for="sentsave" class="col-sm-2 control-label">是否入库</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="petsex" name="petsex">
								<select id="sentsave" name="sentsave">
								<option value="1">是</option>
								<option value="0">否</option>
								</select>
							</div>
						</div>-->
										
					
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
						<button type="button" class="btn btn-primary" onclick="confirmAccept()">
					受理
				</button>
				
				</form>
				
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal-dialog -->
		</div>
		<!-- /.modal -->
		</div>
    <!-- /#wrapper -->
<!-- Nav CSS -->
<link href="${pageContext.request.contextPath }/css/custom.css" rel="stylesheet">
<!-- Metis Menu Plugin JavaScript -->
<script src="${pageContext.request.contextPath }/js/metisMenu.min.js"></script>
<script src="${pageContext.request.contextPath }/js/custom.js"></script>
<script type="text/javascript">
/* 流浪动物信息详情 */
		function detailStray(id) {
			$.post(
				"<%=basePath%>AdminStray/selectStray",
				{"id":id},
				function (data) {
					$("#id").val(data.id);
					$("#fimage1").attr('src',data.fimage);
					$("#fman").val(data.fman);
					$("#femail").val(data.femail);
					$("#faddress").val(data.faddress);
					if(data.fkind == 1){
						
						$("#fkind").html("狗狗");
					}else if(data.skind == 2){
						$("#fkind").html("猫猫");
					}else{
						$("#fkind").html("其他");
					}
					
					if(data.fsex == 1){
						$("#fsex").html("男");
					}else {
						$("#fsex").html("女");
					}
					$("#fcolor").html(data.fcolor);
					$("#ftime").html(data.ftime);
					$("#faddress1").html(data.faddress);
					if(data.fattach == 1){
						$("#fattach").html("有");
					}else {
						$("#fattach").html("无");
					}
					/* $("#fdesc").html(data.fdesc); */
					KindEditor.html('#adfoudpet_id',data.fdesc);
					$("#fman1").html(data.fman);
					$("#ftel").html(data.ftel);
					$("#femail1").html(data.femail);
					if(data.isaccept == 1){
						$("#isaccept").html("已受理");
					}else {
						$("#isaccept").html("未受理");
					}
					
				},
				"json"
			);
		}
		
		/* 受理 */
		function confirmAccept() {
			 $("#fdesc").val($("#adfoudpet_id").val());//信息同步
			$.post(
				"<%=basePath%>adminStray/confirmAccept",
				$("#strayForm").serialize(),
				function (data) {
					alert("已受理!");
					location.href="<%=basePath%>adminStray/stray";
				}
			);
		}
		
		/*删除送养  */
		function delStray(id) {
			var y = confirm("确定要删除吗?");
			if(y){
				$.post(
						"<%=basePath%>adminStray/delstray",
						{"id":id},
						function (data) {
							alert("删除成功!");
							location.href="<%=basePath%>adminStray/stray";
						}
					);
			}
			
		}

</script>

</body>
</html>